package com.home.rest;

import com.github.pagehelper.PageInfo;
import com.home.base.msg.ObjectRestResponse;
import com.home.base.msg.TableResultResponse;
import com.home.base.rest.BaseRestController;
import com.home.biz.HaomaBiz;
import com.home.biz.LtPhoneBiz;
import com.home.entity.LtPhone;
import com.home.entity.SitePhone;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：chenxf
 * @date ：Created in 2020/6/10 13:36
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping("siteFetch")
public class SiteFetchController
        extends BaseRestController<HaomaBiz, SitePhone> {


    @PostMapping("/fetch")
    public ObjectRestResponse fetch(@RequestParam(defaultValue = "0")String provName, @RequestParam(defaultValue = "0")String cityName, @RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchOne(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @GetMapping("/list")
    public TableResultResponse<SitePhone> list(int limit, int offset, String phoneNum, String cityName) {
        //  this.getCurrentId();//检验权限
        List<SitePhone> items = baseBiz.list(limit,offset,phoneNum,cityName);
        PageInfo<SitePhone> pageInfo = new PageInfo<>(items);
        return new TableResultResponse<>(Integer.parseInt(String.valueOf(pageInfo.getTotal())),
                limit, offset,
                items);
    }
}
